package com.vision.sales.cl.ui.component;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.data.shared.ListStore;
import com.vision.sales.cm.data.IHasTransactionStatus;
import com.vision.sales.cm.data.TransactionStatus;

/**
 * 
 * @author Mark
 *
 */
public class TransactionNoCell<T extends IHasTransactionStatus> extends AbstractCell<String> {
	
	ListStore<T> store;
	
	public TransactionNoCell(ListStore<T> store) {
		this.store = store;
	}

	@Override
	public void render(Context context, String transactionNo, SafeHtmlBuilder sb) {
		IHasTransactionStatus i = store.get(context.getIndex());
		TransactionStatus status = i.getStatus();
		String style = "style='color: " + (status == TransactionStatus.PENDING ? "#ff0000" : "#009900") + "'";
        sb.appendHtmlConstant("<span " + style + " qtitle='' qtip='" + status.name() + "'>" + transactionNo + "</span>");
	}

}
